#include <iostream>

using namespace std;

const int N = 15;
int a[N][N];
bool col[N][N], row[N][N], st[N][N][N];
int n = 9;

bool dfs(int x, int y)
{
	if(y == n) 
	{
		y = 0;
		x++;
	}
	if(x == n) return true;
	if(a[x][y] != 0) return dfs(x, y + 1);
	for(int i = 1; i <= n; i++)
	{
		if(row[x][i] || col[y][i] || st[x / 3][y / 3][i]) continue;
		a[x][y] = i;
		row[x][i] = col[y][i] = st[x / 3][y / 3][i] = true;
		if(dfs(x, y + 1)) return true;
		a[x][y] = 0;
		row[x][i] = col[y][i] = st[x / 3][y / 3][i] = false;
	}
	return false;
}

int main()
{
	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < n; j++)
		{
			int x; cin >> x;
			a[i][j] = x;
			if(x != 0) row[i][x] = col[j][x] = st[i / 3][j / 3][x] = true;
		}	
	}
	
	dfs(0, 0);
	
	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < n; j++)
		{
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
	return 0;
}
